package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import dataconnect.ConnectionFactory;

public class FindStock {

	public static void main(String[] args) throws SQLException, IOException {
		File file = new File("s.txt");
//		List list = new ArrayList<>();
		Connection con = ConnectionFactory.getConnection();
		Statement stmt = con.createStatement();
		ResultSet rs = stmt.executeQuery("select number,name from stockinfo");
		BufferedReader brr = new BufferedReader(new FileReader(file));
		StringBuffer sbf = new StringBuffer();
		String s;
		while((s=brr.readLine())!=null){
			sbf.append(s);
		}
		String s1 = sbf.toString();
		while(rs.next()){
			String name = rs.getString(2);
			if(s1.indexOf(name)>0){
				System.out.println(rs.getString(1));
			}
		}
	}
}
